home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kleo / keyselectiondialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-08-19  |  5.9 KB  |  180 lines

  1. /*  -*- c++ -*-
  2.     keyselectiondialog.h
  3.  
  4.     This file is part of libkleopatra, the KDE keymanagement library
  5.     Copyright (c) 2004 Klar├ñvdalens Datakonsult AB
  6.  
  7.     Based on kpgpui.h
  8.     Copyright (C) 2001,2002 the KPGP authors
  9.     See file libkdenetwork/AUTHORS.kpgp for details
  10.  
  11.     Libkleopatra is free software; you can redistribute it and/or
  12.     modify it under the terms of the GNU General Public License as
  13.     published by the Free Software Foundation; either version 2 of the
  14.     License, or (at your option) any later version.
  15.  
  16.     Libkleopatra is distributed in the hope that it will be useful,
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19.     General Public License for more details.
  20.  
  21.     You should have received a copy of the GNU General Public License
  22.     along with this program; if not, write to the Free Software
  23.     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  24.  
  25.     In addition, as a special exception, the copyright holders give
  26.     permission to link the code of this program with any edition of
  27.     the Qt library by Trolltech AS, Norway (or with modified versions
  28.     of Qt that use the same license as Qt), and distribute linked
  29.     combinations including the two.  You must obey the GNU General
  30.     Public License in all respects for all of the code used other than
  31.     Qt.  If you modify this file, you may extend this exception to
  32.     your version of the file, but you are not obligated to do so.  If
  33.     you do not wish to do so, delete this exception statement from
  34.     your version.
  35. */
  36.  
  37. #ifndef __KLEO_UI_KEYSELECTIONDIALOG_H__
  38. #define __KLEO_UI_KEYSELECTIONDIALOG_H__
  39.  
  40. #include <kdialogbase.h>
  41.  
  42. #include <kleo/cryptobackend.h>
  43. #include <gpgmepp/key.h>
  44. #include <kdepimmacros.h>
  45. #include <vector>
  46.  
  47. class QVBoxLayout;
  48. class QCheckBox;
  49. class QPixmap;
  50. class QTimer;
  51. class QListViewItem;
  52. class QRegExp;
  53. class QPoint;
  54.  
  55. namespace Kleo {
  56.   class KeyListView;
  57.   class KeyListViewItem;
  58. }
  59.  
  60. namespace GpgME {
  61.   class KeyListResult;
  62. }
  63.  
  64. namespace Kleo {
  65.  
  66.   class KDE_EXPORT KeySelectionDialog : public KDialogBase {
  67.     Q_OBJECT
  68.   public:
  69.  
  70.     enum KeyUsage {
  71.       PublicKeys = 1,
  72.       SecretKeys = 2,
  73.       EncryptionKeys = 4,
  74.       SigningKeys = 8,
  75.       ValidKeys = 16,
  76.       TrustedKeys = 32,
  77.       CertificationKeys = 64,
  78.       AuthenticationKeys = 128,
  79.       OpenPGPKeys = 256,
  80.       SMIMEKeys = 512,
  81.       AllKeys = PublicKeys | SecretKeys | OpenPGPKeys | SMIMEKeys,
  82.       ValidEncryptionKeys = AllKeys | EncryptionKeys | ValidKeys,
  83.       ValidTrustedEncryptionKeys = AllKeys | EncryptionKeys | ValidKeys | TrustedKeys
  84.     };
  85.  
  86.     KeySelectionDialog( const QString & title,
  87.                         const QString & text,
  88.             const std::vector<GpgME::Key> & selectedKeys=std::vector<GpgME::Key>(),
  89.                         unsigned int keyUsage=AllKeys,
  90.                         bool extendedSelection=false,
  91.             bool rememberChoice=false,
  92.                         QWidget * parent=0, const char * name=0,
  93.                         bool modal=true );
  94.     KeySelectionDialog( const QString & title,
  95.                         const QString & text,
  96.             const QString & initialPattern,
  97.                         unsigned int keyUsage=AllKeys,
  98.                         bool extendedSelection=false,
  99.             bool rememberChoice=false,
  100.                         QWidget * parent=0, const char * name=0,
  101.                         bool modal=true );
  102.     ~KeySelectionDialog();
  103.  
  104.     /** Returns the key ID of the selected key in single selection mode.
  105.         Otherwise it returns a null key. */
  106.     const GpgME::Key & selectedKey() const;
  107.  
  108.     QString fingerprint() const;
  109.  
  110.     /** Returns a list of selected key IDs. */
  111.     const std::vector<GpgME::Key> & selectedKeys() const { return mSelectedKeys; }
  112.  
  113.     /// Return all the selected fingerprints
  114.     QStringList fingerprints() const;
  115.  
  116.     /// Return the selected openpgp fingerprints
  117.     QStringList pgpKeyFingerprints() const;
  118.     /// Return the selected smime fingerprints
  119.     QStringList smimeFingerprints() const;
  120.  
  121.     bool rememberSelection() const;
  122.   protected slots:
  123.     // reimplemented to avoid popping up the help, since we
  124.     // override the button
  125.     void slotHelp();
  126.  
  127.     // Could be used by derived classes to insert their own widget
  128.     QVBoxLayout* topLayout() const { return mTopLayout; }
  129.  
  130.   private slots:
  131.     void slotRereadKeys();
  132.     void slotStartCertificateManager();
  133.     void slotKeyListResult( const GpgME::KeyListResult & );
  134.     void slotSelectionChanged();
  135.     void slotCheckSelection() { slotCheckSelection( 0 ); }
  136.     void slotCheckSelection( Kleo::KeyListViewItem * );
  137.     void slotRMB( Kleo::KeyListViewItem *, const QPoint & );
  138.     void slotRecheckKey();
  139.     void slotTryOk();
  140.     void slotOk();
  141.     void slotCancel();
  142.     void slotSearch( const QString & text );
  143.     void slotSearch();
  144.     void slotFilter();
  145.  
  146.   private:
  147.     void filterByKeyID( const QString & keyID );
  148.     void filterByKeyIDOrUID( const QString & keyID );
  149.     void filterByUID( const QString & uid );
  150.     void showAllItems();
  151.     bool anyChildMatches( const Kleo::KeyListViewItem * item, QRegExp & rx ) const;
  152.  
  153.     void connectSignals();
  154.     void disconnectSignals();
  155.  
  156.     void startKeyListJobForBackend( const Kleo::CryptoBackend::Protocol *, const std::vector<GpgME::Key> &, bool );
  157.     void startValidatingKeyListing();
  158.  
  159.     void init( bool, bool, const QString &, const QString & );
  160.  
  161.   private:
  162.     QVBoxLayout* mTopLayout;
  163.     Kleo::KeyListView * mKeyListView;
  164.     const Kleo::CryptoBackend::Protocol * mOpenPGPBackend;
  165.     const Kleo::CryptoBackend::Protocol * mSMIMEBackend;
  166.     QCheckBox * mRememberCB;
  167.     std::vector<GpgME::Key> mSelectedKeys, mKeysToCheck;
  168.     unsigned int mKeyUsage;
  169.     QTimer * mCheckSelectionTimer;
  170.     QTimer * mStartSearchTimer;
  171.     // cross-eventloop temporaries:
  172.     QString mSearchText;
  173.     Kleo::KeyListViewItem * mCurrentContextMenuItem;
  174.     int mTruncated, mListJobCount, mSavedOffsetY;
  175.   };
  176.  
  177. }
  178.  
  179. #endif // __KLEO_UI_KEYSELECTIONDIALOG_H__
  180.